package com.estar.assistsurvy.adapter;

import java.util.List;

import com.estar.assistsurvy.R;
import com.estar.assistsurvy.entity.CityVO;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class SelectCityAdapter extends BaseAdapter {

	private List<CityVO> cityList;
	private LayoutInflater inflater;
	public SelectCityAdapter(List<CityVO> cityList, Context context) {
		super();
		this.cityList = cityList;
		inflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return cityList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return cityList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder;
		if(convertView==null){
			convertView=inflater.inflate(R.layout.spinner_item, null);
			holder=new ViewHolder();
			holder.text=(TextView) convertView.findViewById(R.id.state_text);
			convertView.setTag(holder);
		}else{
			holder=(ViewHolder) convertView.getTag();
		}
		holder.text.setText((CharSequence) cityList.get(position).getAreaName());
		return convertView;
	}
	
	private class ViewHolder{
		private TextView text;
	}

}
